﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Pibby.UI
{
	public partial class ExceptionMessageBox : Form
	{
		private string _message;
		private List<string> _callStack;

		public ExceptionMessageBox()
		{
			InitializeComponent();

			this._callStack = new List<string>();
		}

		public ExceptionMessageBox(Exception ex)
			: this ()
		{
			if (ex != null)
			{
				this._message = ex.Message;
				
				this._callStack.AddRange (ex.StackTrace.Split(new Char[] { '\n'}, 
											StringSplitOptions.RemoveEmptyEntries));
			}
		}

		private void ExceptionMessageBox_Load(object sender, EventArgs e)
		{
			this.exceptionTextBox.Text = this._message;

			foreach (string item in this._callStack)
			{
				this.stackTraceListBox.Items.Add (item);
			}
		}
	}
}
